package com.tnsw.facebookautoliker.helper.command;

import java.util.ArrayList;

import android.content.Context;

import com.tnsw.facebookautoliker.database.DBManager;
import com.tnsw.facebookautoliker.helper.FacebookCommandObject;
import com.tnsw.facebookautoliker.helper.GeneralManager;

public class SQLiteExecute extends FacebookCommandObject {

	private GeneralManager gm ;
	private DBManager dbm;
	
	private String sql;
	private Object[] values = null;
	
	public SQLiteExecute(Context context, String sql, Object[] values) {
		super(context);
		super.tag = "SQLiteExecute";
		
		this.gm = GeneralManager.getInstance();
		this.dbm = DBManager.getInstance(context);
		
		this.sql = sql;
		this.values = values;
		
		this.setTag("sql", sql);
		
		if (values != null) {
			this.setTag("values", values);
		}
	}
	
	@Override
	public void execute() {
		super.execute();
		
		boolean b;
		if (this.values == null) {
			b = this.dbm.executeSQL(this.sql, false);
		} else {
			b = this.dbm.executeSQL(this.sql, this.values, false);
		}
		
		this.setTag("result", b);
		super.fbm.updateCommandStatus(this, 200, null);
		
	}

	
}
